package com.internetCafes.spms.web.customer.controller;

import com.internetCafes.spms.common.base.BaseWebController;
import com.internetCafes.spms.common.utils.entity.RR;
import com.internetCafes.spms.common.utils.entity.page.PageItemDTO;
import com.internetCafes.spms.common.utils.entity.page.PageItemVO;
import com.internetCafes.spms.core.annotation.SysLog;
import com.internetCafes.spms.web.customer.bizservice.customer.IEntCustomerMaterialBizService;
import com.internetCafes.spms.web.customer.model.customer.material.MaterialPagingReq;
import com.internetCafes.spms.web.customer.model.customer.material.MaterialPagingRes;
import com.internetCafes.spms.web.customer.model.customer.material.MaterialSaveReq;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 客户报考资料前端控制器
 * </p>
 *
 * @author Zj
 * @since 2021-10-20
 */
@RestController
@RequestMapping("/ent/customer/material")
public class EntCustomerMaterialController extends BaseWebController {

    @Autowired
    private IEntCustomerMaterialBizService materialBizService;

    /**
     * 客户报考资料分页
     */
    @PostMapping("/paging")
    public RR<PageItemVO<MaterialPagingRes>> paging(@RequestBody PageItemDTO<MaterialPagingReq> req) {
        return RR.success(materialBizService.paging(req));
    }

    /**
     * 客户报考资料删除
     */
    @SysLog("客户报考资料删除")
    @DeleteMapping("/{idList}")
    public RR<Void> delete(@PathVariable List<Long> idList) {
        return materialBizService.delete(idList) ? RR.success() : RR.fail();
    }

    /**
     * 新增客户报考资料
     */
    @SysLog("客户报考资料新增")
    @PostMapping("/save")
    public RR<Void> save(@RequestBody MaterialSaveReq req) {
        return materialBizService.save(req) ? RR.success() : RR.fail();
    }
}
